{% extends 'car_system/base.html' %}

{% block title %}注册 - 汽车数据分析系统{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header bg-primary text-white text-center">
                <h4><i class="fas fa-user-plus me-2"></i>用户注册</h4>
            </div>
            <div class="card-body">
                <form method="POST">
                    {% csrf_token %}
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label for="{{ form.username.id_for_label }}" class="form-label">用户名</label>
                            {{ form.username }}
                            {% if form.username.errors %}
                                <div class="text-danger">
                                    {% for error in form.username.errors %}
                                        {{ error }}
                                    {% endfor %}
                                </div>
                            {% endif %}
                            <div class="form-text">必填。150个字符或更少。字母、数字和@/./+/-/_。</div>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label for="{{ form.email.id_for_label }}" class="form-label">电子邮件</label>
                            {{ form.email }}
                            {% if form.email.errors %}
                                <div class="text-danger">
                                    {% for error in form.email.errors %}
                                        {{ error }}
                                    {% endfor %}
                                </div>
                            {% endif %}
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label for="{{ form.password1.id_for_label }}" class="form-label">密码</label>
                            {{ form.password1 }}
                            {% if form.password1.errors %}
                                <div class="text-danger">
                                    {% for error in form.password1.errors %}
                                        {{ error }}
                                    {% endfor %}
                                </div>
                            {% endif %}
                            <div class="form-text">
                                <ul>
                                    <li>密码不能与个人信息太相似。</li>
                                    <li>密码至少8个字符。</li>
                                    <li>密码不能是常见密码。</li>
                                    <li>密码不能全为数字。</li>
                                </ul>
                            </div>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label for="{{ form.password2.id_for_label }}" class="form-label">确认密码</label>
                            {{ form.password2 }}
                            {% if form.password2.errors %}
                                <div class="text-danger">
                                    {% for error in form.password2.errors %}
                                        {{ error }}
                                    {% endfor %}
                                </div>
                            {% endif %}
                            <div class="form-text">请再次输入密码，以确认无误。</div>
                        </div>
                    </div>
                    <div class="d-grid gap-2 mt-3">
                        <button type="submit" class="btn btn-primary btn-lg">注册</button>
                    </div>
                </form>
            </div>
            <div class="card-footer text-center">
                <p class="mb-0">已有账号？ <a href="{% url 'login' %}" class="text-decoration-none">立即登录</a></p>
            </div>
        </div>
    </div>
</div>
{% endblock %} 